<template>
  <el-row class="tac">
    <el-col :span="12" style="width:200px">
      <el-menu default-active="2" @open="handleOpen" @close="handleClose" router>
        <el-submenu index="1" style="width:100%">
          <template slot="title">
            <i class="el-icon-s-shop"></i>
            <span>店铺管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/merchant/merchantAdd">申请店铺</el-menu-item>
            <el-menu-item index="/merchant/MerchantRead">查看店铺</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="2" style="width:100%">
          <template slot="title">
            <i class="el-icon-school"></i>
            <span>商品管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/merchant/goodslist">商品列表</el-menu-item>
            <el-menu-item index="/merchant/goodsuplist">库存列表</el-menu-item>
            <el-menu-item index="/merchant/goodsadd">商品添加</el-menu-item>
            <el-menu-item index="/merchant/typeslist">商品分类</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="3" style="width:100%">
          <template slot="title">
            <i class="el-icon-school"></i>
            <span>订单管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/merchant/orderlist">订单列表</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-col>
  </el-row>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions } = createNamespacedHelpers("shop");
export default {
  methods: {
    ...mapActions(["getMerchantAsync"]),
    handleOpen(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    }
  },
  async created() {
    let userName = sessionStorage.getItem("userName");
    let shopData = await this.getMerchantAsync(userName);
    if (shopData) {
      sessionStorage.setItem("isShop", true);
    } else {
      sessionStorage.setItem("isShop", false);
    }
  }
};
</script>

<style>
a {
  text-decoration: none;
  color: #2c3e50;
}
</style>